<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>Leaflet debug page - Control Layers</title>
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
		<link rel="stylesheet" href="../../dist/leaflet.css" />
		<link rel="stylesheet" href="../css/screen.css" />
		<script type="importmap">
			{
				"imports": {
					"leaflet": "../../dist/leaflet-src.js"
				}
			}
		</script>
	</head>
	<body>
		<div id="map"></div>
		<style>
			.grayscale-tile {
				filter: grayscale(1);
			}
		</style>
		<script type="module">
			import {LeafletMap, TileLayer, Control, Circle, Polygon, GeoJSON} from 'leaflet';

			const GrayscaleTileLayer = TileLayer.extend({
				createTile(...args) {
					const element = TileLayer.prototype.createTile.call(this, ...args);
					element.classList.add('grayscale-tile');
					return element;
				}
			});

			const map = new LeafletMap('map').setView([50.5, 0], 5);
			const tileUrl = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
			const regularTiles = new TileLayer(tileUrl).addTo(map);
			const blackAndWhiteTiles = new GrayscaleTileLayer(tileUrl);

			new Control.Layers({
				'OSM': regularTiles,
				'OSM BW': blackAndWhiteTiles
			}, {
				'Circle': new Circle([53, 4], 111111).addTo(map),
				'Polygon': new Polygon([[48, -3], [50, -4], [52, 4]]),
				'GeoJSON': new GeoJSON({
					type: 'Polygon',
					coordinates: [[
						[5.4931640625, 51.781435604431195],
						[0.9008789062499999, 53.35710874569601],
						[-2.30712890625, 51.795027225829145],
						[2.8125, 49.109837790524416],
						[5.4931640625, 51.781435604431195]
					]]
				}),
			}, {
				collapsed: false
			}).addTo(map);
		</script>
	</body>
</html>
